﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

using AutoMapper;
using Happy.AutoMapper;

namespace AutoMapperStudy
{
    class Program
    {
        static void Main(string[] args)
        {
            Mapper.Initialize(cfg =>
            {
                cfg.AddProfile(new Profile());
            });
            Mapper.Initialize(cfg =>
            {
            });

            Mapper.Map(new TagView(), new Tag());
        }
    }

    public class Profile : AutoMapper.Profile
    {
        protected override void Configure()
        {
            Mapper
                .CreateMap<TagView, Tag>()
                .IgnoreNotPublicSetter();
        }

        public override string ProfileName
        {
            get { return this.GetType().Name; }
        }
    }

    public sealed class Tag
    {
        public Guid Id { get; set; }

        public byte[] OptimisticKey { get; set; }

        public string Name { get; set; }

        public string Category { get; private set; }

        public string Description { get; set; }

        public int Order { get; set; }
    }

    public sealed class TagView
    {
        public Guid Id { get; set; }

        public byte[] OptimisticKey { get; set; }

        public string Name { get; set; }

        public string Category { get; set; }

        public string Description { get; set; }

        public int Order { get; set; }
    }
}
